#ifndef _ED_AES_H_
#define _ED_AES_H_
#include "stdbool.h"

#define AES_KEY  "c2mujs64hr8ywbfk"

#define FTD_HERAD1       0xA1B2C3D4
#define FTD_HERAD2       0x1A2B3C4D

#define FTD_TAIL1        0xC1D2E3F4
#define FTD_TAIL2        0x1C2D3E4F


#pragma pack(push,1)
typedef struct file_tail_data_s
{
    unsigned int    head1;
    unsigned int    head2;
    unsigned int    file_len;     // 
    unsigned int    rest_len;     // 
    unsigned int    sum;          // 
    unsigned int    crc;          // CRC
    unsigned int    tail1;
    unsigned int    tail2;
}file_tail_data_t;
#pragma pack(pop)

inline int (is_file_tail_data)(file_tail_data_t * p)
{
    if (FTD_HERAD1 == p->head1 && FTD_HERAD2 == p->head2 && FTD_TAIL1 == p->tail1 && FTD_TAIL2 == p->tail2)
    {
        return 1;
    }
    return 0; 
}

bool aes_decrypt(unsigned char * in_buf, int in_len, 
                 unsigned char * out_buf, int * out_len);

#endif
